package com.forekonw.demo12;

import com.forekonw.demo9.B;

import java.io.*;

public class BufferedDemo {
    public static void main(String[] args) {
        try {
            FileReader r = new FileReader("FileCopy.java");
            BufferedReader br = new BufferedReader(r);
            FileWriter rr = new FileWriter("new_FileCopy.java");
            BufferedWriter bw = new BufferedWriter(rr);

            //读取源文件的一个文本行
            String line = br.readLine();
            while (line != null){
                //将读取的一个文件写到目标文件中
                bw.write(line);
                //换行
                bw.newLine();
                line = br.readLine();
            }
            //释放资源
            br.close();
            bw.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
